package com.bishe.common.listener;

import com.bishe.common.controller.MailController;
import com.bishe.common.utils.MailMsg;
import jakarta.mail.MessagingException;
import lombok.RequiredArgsConstructor;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

@Component
@RequiredArgsConstructor
public class MailListener {
    private   final MailMsg mailMsg;
    @RabbitListener(bindings = @QueueBinding(
            value = @Queue(name = "mail.success.queue", durable = "true"),
            exchange = @Exchange(name = "mail.topic"),
            key = "mail.success"
    ))
    public void listenPaySuccess(String email) throws MessagingException {
        mailMsg.mail(email);
    }
}
